#ifndef __WINDOW_H__
#define __WINDOW_H__

#include <Windows.h>
#include <vector>
#include <string>

#include "MRect.h"
#include "IEvent.h"

class View;

class Window : public MouseEvents
{
public:
						Window( MRect rect = MRect( 400.0f, 300.0f, 300.0f, 200.0f ), std::wstring title = TEXT( "Window" ) );
						Window( const WNDCLASSEX& wndClass, MRect rect, std::wstring title );

	virtual				~Window( );
	
	virtual void		update( );
	//	MouseEvents
	void				mouseMove( const IEvent& event );
	void				wheelMove( const IEvent& event );
	void				leftMouseDown( const IEvent& event );
	void				leftMouseUp( const IEvent& event );
	//

	void				showWindow();
	void				close();

	void				setRect( MRect rect );
	MRect				rect();
	void				setTitle( std::wstring title );
	std::wstring		title();
	HWND				hWnd();

	MPoint				clientToScreen( MPoint point );
	MRect				getClientRect();
	void				clipCursor( MRect& rect );

	void				removeViewWithSubviewsFromHierarchy( View* view );

	// tracking views
	void				addToTrackingViews( View* view );
	void				removeViewFromTrackingViews( View* view );
	void				removeViewWithSubViewsFromTrackingViews( View* view );
	
	//void				contentView( View* view );
	View*				contentView( );

#ifdef _DEBUG
	void				dumpViews();
#endif

private:

	void				init( WNDCLASSEX wndClass, MRect rect, std::wstring title );


	void				_trackView( const MPoint& point, View* view );
public:
	View*				_contentView; // weak ref to main window view controller view for root view hierarhy

private:
	std::wstring		_title;
	MRect				_rect;
	HWND				_hWnd;
	WNDCLASSEX			_wndClass;
	
	// tracking roll over roll out views
	std::vector< View* >	_trackingViews;
public:
	View*				prevHitView; // for rollOver rollOut views events

};


#endif